<template>
  <el-form label-width="auto">
    <el-form-item label="流程名称">
      <el-text>{{ element.name }}</el-text>
    </el-form-item>
    <el-form-item label="流程ID">
      <el-text>{{ element.id }}</el-text>
    </el-form-item>
    <el-form-item label="自定义名称：">
      <el-col :span="18">
        <el-input v-model="elementName"></el-input>
      </el-col>
      <el-col :span="1"></el-col>
      <el-col :span="5">
        <el-button @click="handlerUpdataName" plain type="primary"><el-icon>
            <Edit />
          </el-icon></el-button>
      </el-col>

    </el-form-item>
  </el-form>
</template>

<script setup>
import { ref } from 'vue'
const element = defineModel("element")
const props = defineProps({
  bpmnModeler: Object
})
const elementName = ref('')
function handlerUpdataName() {
  element.value.name = elementName.value
  if (elementName.value) {
    const editElement = props.bpmnModeler.get("elementRegistry").get(element.value.id)
    const modeling = props.bpmnModeler.get("modeling")
    modeling.updateProperties(editElement, { name: elementName.value })
    elementName.value = ''
  }
}
</script>

<style lang="less" scoped></style>